// 子集

package Leetcode;

import java.util.ArrayList;
import java.util.List;

class solution_078 {
    public List<List<Integer>> subsets(int[] nums) {
        List<List<Integer>> result = new ArrayList<>();
        int currentPos = 0;
        result.add(new ArrayList<>());
        DFS(result, nums, currentPos, new ArrayList<Integer>());
        return result;
    }

    public void DFS(List<List<Integer>> result, int[] nums, int currentPos, List<Integer> combination) {
        if (currentPos > nums.length)
            return;
        for (int i = currentPos; i < nums.length; i++) {
            combination.add(nums[i]);
            result.add(new ArrayList<>(combination));
            DFS(result, nums, i + 1, combination);
            combination.remove(combination.size() - 1);
        }
    }
}

public class Solution078 {

}
